﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class VoteModel extends BaseModel
{

    var $table  = 'vote_topic';	

    var $_page_rows = 20;	
	
    /* 插入数据 */
    function post($data)
    {    
	
		$time = time();     
    
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>$data["user_id"],'cat_id'=>$data["cat_id"],'name'=>$data["name"],'title'=>$data["title"],'filename'=>$data["filename"],'filepath'=>$data["filepath"],'keywords'=>$data["keywords"],'description'=>$data["description"],'modue'=>"$data[modue]",'content'=>$data["content"],'add_time'=>"$time"), 'mode' => 'INSERT'));

        
    }

    function show()
    {   
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"",'url' => 'admin/?app=vote&act=index'));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"",'order' =>'posttime desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;
        
    }


    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>$data["user_id"],'cat_id'=>$data["cat_id"],'name'=>$data["name"],'title'=>$data["title"],'filename'=>$data["filename"],'filepath'=>$data["filepath"],'keywords'=>$data["keywords"],'description'=>$data["description"],'modue'=>"$data[modue]",'content'=>$data["content"],'add_time'=>"$time"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }


    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }


}




?>